﻿
@{
    ViewBag.IsBBSMain = true;
    List<BBS_Forums> forList = ViewBag.ForList;
    bool isLogin = ViewBag.IsLogin;
    UserInfo user = ViewBag.User;
    Layout = "~/Views/Shared/_Layout_BBS.cshtml";
    if (Model.TopItem.PosterAvatar.IsNullOrEmpty())
    {
        Model.TopItem.PosterAvatar = Url.Content("~/_theme/default.jpg");
    }
    string fName = forList.Single(it => it.Fid == Model.TopItem.Fid).Name;
    ViewBag.Title = Model.PosItem.Title + " - " + fName.TryToString().Trim() + " - .NET文档园";
}
@using Infrastructure.DbModel
@using SyntacticSugar
@using Infrastructure.DbModel;
@using Infrastructure.Pub;
@section css{
    <link href="~/_theme/ueditor/utf8-net/third-party/SyntaxHighlighter/shCoreDefault.css" rel="stylesheet" />
    <link href="~/_theme/css/bbs-detail.css" rel="stylesheet" />
}
@section js{
    <script src="~/_theme/ueditor/utf8-net/ueditor.config.js"></script>
    <script src="~/_theme/ueditor/utf8-net/ueditor.all.js"></script>
    <script>
        var ue = UE.getEditor('container', {
            toolbars: [[
                'fullscreen', 'source', 'fontsize', 'insertcode', 'paragraph', 'fontfamily', 'forecolor', 'backcolor',
                'bold', 'italic', 'underline',
                'simpleupload', 'emotion'
            ]]
        });
        layui.use(['form', 'laydate', 'ejq', 'ajaxforms'], function () {
            var form = layui.form()
            , layer = layui.layer
            , laydate = layui.laydate;
            var $ = layui.ajaxforms;
            var $btnSubmit = $("#btnSubmit");
            var $btnBack = $("#btnBack");
            var $favorites = $(".my-favorites i");
            var $hideTid = $("#hideTid");
            var $hideFid = $("#hideFid");
            var $favoritesText = $("#favoritesText");
            var $iReplies = $(".iReply");
            $btnBack.click(function () {
                var url = document.referrer;
                var thisUrl = location.href;
                if (thisUrl == url) {
                    window.location.href = $.action.urlContent("Ask");
                } else {
                    window.location.href = url;
                }
            });
            $iReplies.click(function () {
                ue.setContent("<p><span style=\"color:#4f99cf\">@@" + $(this).data("name") + "</span>：</p>", ue.getContent() != null && ue.getContent() != "");
                $(document).scrollTop(10000);
            });
            $favorites.click(function () {
                var th = $(this);
                $.ajax({
                    url: $.action.url("AddFavorites", null, "Main", "BBS"),
                    cache: false,
                    type: "post",
                    data: { tid: $hideTid.val(), fid: $hideFid.val() },
                    success: function (msg) {
                        if (msg.ResultInfo == "-1") {
                            window.location.href = $("#hidLoginUrl").val();
                        } else if (msg.IsSuccess) {
                            layer.msg(msg.ResultInfo, { icon: 6, shade: 0.3 });
                            if (msg.Status == "1") {
                                $favoritesText.text("取消");
                            } else {
                                $favoritesText.text("收藏");
                            }
                        } else {
                            layer.msg(msg.ResultInfo, { icon: 6, shade: 0.3 });
                            $favoritesText.text("操作失败");
                        }
                    }
                })
            });
            $btnSubmit.click(function (e) {
                e.preventDefault();
                var c = ue.getContent();
                if (c == "") {
                    layer.msg("回复不能为空！");
                } else {
                    var index = layer.load(1, {
                        shade: [0.3, '#fff']
                    });
                    $("form").ajaxSubmit({
                        url: $.action.url("RepliesSubmit", null, "Main", "BBS"),
                        cache: false,
                        success: function (msg) {
                            if (msg.ResultInfo == "-1") {
                                window.location.href = $("#hidLoginUrl").val();
                            } else if (msg.IsSuccess) {
                                window.location.reload();
                            } else {
                                layer.msg(msg.ResultInfo);
                            }
                            layer.close(index);
                        }, error: function () {
                            layer.close(index);
                        }
                    })
                }
            });

        });
    </script>
    <script src="~/_theme/ueditor/utf8-net/third-party/SyntaxHighlighter/shCore.js"></script>
    <script type="text/javascript">SyntaxHighlighter.all();</script>
}
@model Infrastructure.ViewModels.BBS.DetailResult
<input type="hidden" id="hidLoginUrl" value="@Url.Content("~/Home/Login")" />
<input type="hidden" id="hideTid" value="@Model.TopItem.Tid" />
<input type="hidden" id="hideFid" value="@Model.TopItem.Fid" />
<div class="content detail" style="width:100%">
    <h1>@Model.PosItem.Title <a id="btnBack" class="layui-btn">返回</a></h1>
    <div class="fly-tip fly-detail-hint" data-id="5467">
        <span>@fName</span>
        <div class="fly-list-hint">
            <i class="iconfont" title="回答"></i> @Model.TopItem.Replies
            <i class="iconfont" title="人气"></i> @Model.TopItem.Views
        </div>
    </div>
    <div class="detail-about">
        <a class="jie-user" href="~/UserCenter/PublicInfo?id=@Model.TopItem.Posterid"> <img src="@Model.TopItem.PosterAvatar.Replace(@"/30",@"/100")" alt="该叫什么" /> <cite> @Model.PosItem.Poster <em>发布于@(DateSugar.DateStringFromNow(Model.TopItem.Postdatetime.TryToDate().ToLocalTime()))</em> </cite> </a>
        <div class="detail-hits" data-id="5467">
            <span style="color:#FF7200">悬赏：@Model.TopItem.Rate 飞吻</span>
        </div>
    </div>
    <div class="detail-body photos" style="margin-bottom: 20px;">
        @Html.Raw(Model.PosItem.Message)
    </div>
    <p class="my-favorites">
        <i class="layui-icon">
            &#xe600;<label id="favoritesText">@Model.IsFavorites.IIF("取消", "收藏")</label>
        </i>
        <div class="bdsharebuttonbox">
            <a style="background:none;padding-left: 0;">&nbsp; 分享朋友圈：</a>
            <a href="#" class="bds_qzone" data-cmd="qzone"></a>
            <a href="#" class="bds_tsina" data-cmd="tsina"></a>
            <a href="#" class="bds_weixin" data-cmd="weixin"></a>
        </div>
        <script>window._bd_share_config = { "common": { "bdSnsKey": {}, "bdText": "分享朋友圈：", "bdMini": "2", "bdPic": "", "bdStyle": "0", "bdSize": "16" }, "share": {}, "image": { "viewList": ["qzone", "tsina", "weixin"], "viewText": "分享到：", "viewSize": "16" }, "selectShare": { "bdContainerClass": null, "bdSelectMiniList": ["qzone", "qzone", "weixin"] } }; with (document) 0[(getElementsByTagName('head')[0] || body).appendChild(createElement('script')).src = 'http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion=' + ~(-new Date() / 36e5)];</script>
    </p>
    <p class="top-edit">
        @if (isLogin && (user.Id == Model.TopItem.Posterid || user.RoleId != PubEnum.RoleType.User.TryToInt()))
        {
            if (PubEnum.RoleType.Admin.TryToInt() == user.RoleId || DateSugar.IsSameDay(Model.TopItem.Postdatetime.TryToDate().ToLocalTime(), DateTime.Now))
            {
             <a href="/BBS/Main/Ask?id=@Model.TopItem.Tid">修改</a>
            }
        }
    </p>
    <a name="comment"></a>
    <h2 class="page-title">热忱回答<span>（<em id="jiedaCount">@Model.TopItem.Replies.TryToInt()</em>）</span></h2>
    <ul class="jieda photos" id="jieda">
        @if (Model.PostsChildren.IsValuable())
        {
            foreach (var item in Model.PostsChildren)
            {
                if (item.Avatar.IsNullOrEmpty())
                {
                    item.Avatar = Url.Content("~/_theme/default.jpg");
                }
                <li data-id="19288">
                    <a name="item-1480412603361"></a>
                    <div class="detail-about detail-about-reply">
                        <a class="jie-user" href="~/UserCenter/PublicInfo?id=@item.Posterid"> <img src="@item.Avatar" alt="@item.Poster" layer-index="0" /> <cite> <i>@item.Poster</i> <em style="padding:0 ; color: #FF7200;">VIP0</em> </cite> </a>
                        <div class="detail-hits">
                            <span>@DateSugar.DateStringFromNow(item.Postdatetime.TryToDate().ToLocalTime())</span>
                        </div>
                    </div>
                    <div class="detail-body jieda-body">
                        @Html.Raw(item.Message)
                    </div>
                    <div class="jieda-reply">
                        <span class="jieda-zan " type="zan"> <i class="iconfont icon-zan"></i> <em>0</em> </span>
                        <span data-name="@item.Poster" data-id="@item.Posterid" type="reply" class="iReply"> <i class="iconfont icon-svgmoban53"></i> 回复 </span>
                    </div>
                </li>
            }
        }
    </ul>
    <div class="layui-form layui-form-pane">
        <form method="post">
            <div class="layui-form-item layui-form-text">
                <div class="layui-input-block">
                    <input type="hidden" id="hidTid" name="tid" value="@Model.TopItem.Tid" />
                    <input type="hidden" id="hidFid" name="fid" value="@Model.TopItem.Fid" />
                    <!-- 加载编辑器的容器 -->
                    <script id="container" name="Content" style="height:200px" type="text/plain">
                    </script>
                </div>
            </div>
            <div class="layui-form-item">
                <input type="hidden" name="jid" value="5467" />
                <button id="btnSubmit" class="layui-btn" lay-filter="*" lay-submit="">提交回答</button>
            </div>
        </form>
    </div>
</div>